package com.fix.demo.day2;


import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.fix.demo.day1.Student;

@Controller
public class ThymeleafController {
	
	@RequestMapping("/th")
	public String test(ModelMap map) {
		Student st = new Student();
		st.setStname("石一舟");
		st.setAge(18);
		st.setPassword("888888");
		st.setBirthday(new Date());
		
		map.addAttribute("stu", st);
		map.addAttribute("loginuser", "OK");  //登录标志
		map.addAttribute("role", "admin");
		
		//-------------
		Student s1= new Student("temo", "123", 12);
		Student s2= new Student("vn", "456", 13);
		Student s3= new Student("js", "678", 14);
		Student s4= new Student("dema", "888", 15);
		List<Student> list =new ArrayList<Student>();
		list.add(s1);
		list.add(s2);
		list.add(s3);
		list.add(s4);
		map.addAttribute("heros", list);
		
		// 分页
		int sz[]=new int[10];
		for (int i = 0; i < sz.length; i++) {
			sz[i]=i+1;
		}
		map.addAttribute("pages", sz);
		map.addAttribute("cur", 5);    //当前页5
		return "leaf";
	}

}
